/*

 * Licensed to the Apache Software Foundation (ASF) under one

 * or more contributor license agreements.  See the NOTICE file

 * distributed with this work for additional information

 * regarding copyright ownership.  The ASF licenses this file

 * to you under the Apache License, Version 2.0 (the

 * "License"); you may not use this file except in compliance

 * with the License.  You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */

package com.bff.gaia.unified.runners.fnexecution.environment;



import com.bff.gaia.unified.model.pipeline.v1.RunnerApi;

import com.bff.gaia.unified.model.pipeline.v1.RunnerApi.Environment;

import com.bff.gaia.unified.runners.fnexecution.GrpcFnServer;

import com.bff.gaia.unified.runners.fnexecution.ServerFactory;

import com.bff.gaia.unified.runners.fnexecution.artifact.ArtifactRetrievalService;

import com.bff.gaia.unified.runners.fnexecution.control.ControlClientPool;

import com.bff.gaia.unified.runners.fnexecution.control.FnApiControlClientPoolService;

import com.bff.gaia.unified.runners.fnexecution.control.SdkHarnessClient;

import com.bff.gaia.unified.runners.fnexecution.logging.GrpcLoggingService;

import com.bff.gaia.unified.runners.fnexecution.provisioning.StaticGrpcProvisionService;

import com.bff.gaia.unified.sdk.fn.IdGenerator;



/** Creates {@link Environment environments} which communicate to an {@link SdkHarnessClient}. */

public interface EnvironmentFactory {

  /** Creates an active {@link Environment} and returns a handle to it. */

  RemoteEnvironment createEnvironment(RunnerApi.Environment environment) throws Exception;



  /** Provider for a {@link EnvironmentFactory} and {@link ServerFactory} for the environment. */

  interface Provider {



    /** Creates {@link EnvironmentFactory} for the provided GrpcServices. */

    EnvironmentFactory createEnvironmentFactory(

		GrpcFnServer<FnApiControlClientPoolService> controlServiceServer,

		GrpcFnServer<GrpcLoggingService> loggingServiceServer,

		GrpcFnServer<ArtifactRetrievalService> retrievalServiceServer,

		GrpcFnServer<StaticGrpcProvisionService> provisioningServiceServer,

		ControlClientPool clientPool,

		IdGenerator idGenerator);



    /** Create the {@link ServerFactory} applicable to this environment. */

    default ServerFactory getServerFactory() {

      return ServerFactory.createDefault();

    }

  }

}